#!/bin/env python

import time
import cv2
import numpy as np

pic_path = "../resource/pic/img_002.jpg"
windowName = pic_path

cv2.namedWindow(windowName, cv2.WINDOW_NORMAL)
cv2.resizeWindow(windowName, 1500, 500)
pic = cv2.imread(pic_path)
graph = np.zeros(pic.shape, np.uint8)


cv2.line(graph, (30, 30), (150, 150), (190, 190, 190), 1, lineType=cv2.LINE_8)
cv2.rectangle(graph, (50, 50), (100, 100), (255, 190, 190), 1, lineType=cv2.LINE_8)
cv2.circle(graph, (50, 50), 50, (0, 255, 0))
cv2.ellipse(graph, (90, 90), (30, 60), 45, 0, 360, (0, 0, 255))

pts = np.array([(50, 100), (50, 150), (100, 160)], np.int32)
cv2.polylines(graph, [pts], True, (0, 0, 255))

pts2 = np.array([(100, 30), (100, 50), (150, 100)], np.int32)
cv2.fillPoly(graph, [pts2], (0, 0, 255))

cv2.putText(graph, 'put Text', (10, 150), cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 255))

img = cv2.add(graph, pic)
cv2.imshow(windowName, np.hstack((pic, graph, img)))

while True:
    if cv2.waitKey(0) == ord('q'):
        break

print('销毁窗口')
cv2.destroyAllWindows()
